import 'package:baselib/utils/image_util.dart';
import 'package:baselib/widgets/comm_app_bar.dart';
import 'package:baselib/widgets/comm_click_widget.dart';
import 'package:baselib/widgets/gradient_card_view.dart';
import 'package:baselib/widgets/inkwell_button.dart';
import 'package:flutter/material.dart';
import 'package:framelib/utils/color_util.dart';
import 'package:framelib/utils/drawable_util.dart';
import 'package:framelib/utils/px_util.dart';
import 'package:framelib/utils/string_util.dart';
import 'package:framelib/widgets/comm_widget_manager.dart';
import 'package:framelib/widgets/main_gradient_button.dart';
import 'package:framelib/widgets/page_widget.dart';
import 'package:get/get.dart';
import 'package:module_business/module_my/viewmodel/profile_edit_view_model.dart';
/**
 * profile edit主页
 */
class ProfileEditPage extends GetWidget<ProfileEditViewModel> {
  @override
  Widget build(BuildContext context) {
    return PageWidget.build(
        builder: (ProfileEditViewModel model){
          return PageWidget.PageScaffoldWidget(
            isShowBg: true,
            appBar: CommAppBar(
              backgroundColor: ColorUtil.instance.color_transparent,
              titleStr: StringUtil.instance.Profile_Edit,
            ),
            body: ListView(
              padding: EdgeInsets.only(
                left: PxUtil.instance.px_15,
                right: PxUtil.instance.px_15,
              ),
              shrinkWrap: true,
              children: [
                Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: [
                    InkWellButton(
                      onPressed: ()=>model.onIconPressed(),
                      child: Container(
                        width: PxUtil.instance.px_82,
                        height: PxUtil.instance.px_82,
                        margin: EdgeInsets.only(
                          top: PxUtil.instance.px_60,
                          bottom: PxUtil.instance.px_46,
                        ),
                        alignment: Alignment.center,
                        decoration: BoxDecoration(
                            gradient: LinearGradient(
                                begin: Alignment.topCenter,
                                end: Alignment.bottomCenter,
                                colors: [
                                  ColorUtil.instance.color_AE2CF1,
                                  ColorUtil.instance.color_7776FF,
                                ]),
                            borderRadius: BorderRadius.circular(PxUtil.instance.px_41)
                        ),
                        child:(model.myInfo?.icon??'').isEmpty?
                        ImagesUtil.loadAssetImage(
                            DrawableUtil.instance.icon_register_camera,
                            height: PxUtil.instance.px_32,
                            fit: BoxFit.fitHeight
                        ):
                        CommWidgetManager.buildCicleImagWidget(
                          model.myInfo?.icon,
                          placeholder: DrawableUtil.instance.icon_register_camera,
                          width: PxUtil.instance.px_82,
                          height: PxUtil.instance.px_82,
                          roundRadius: PxUtil.instance.px_41,
                          backgroundColor: ColorUtil.instance.color_f2f2f2,
                          padding: EdgeInsets.only(),
                          margin: EdgeInsets.only(),
                        ),
                      ),
                    ),
                  ],
                ),
                //name
                CommClickWidget(
                  title: '${StringUtil.instance.Name}：',
                  itemHeight: PxUtil.instance.px_46,
                  titlecColor: ColorUtil.instance.color_white,
                  titleFontWeight: FontWeight.w500,
                  titleSize: PxUtil.instance.px_13,
                  contColor: ColorUtil.instance.color_white,
                  contFontSize: PxUtil.instance.px_13,
                  contFontWeight: FontWeight.w500,
                  cont: model.myInfo?.nickname??'',
                  itemBoxDecoration: BoxDecoration(
                    color: ColorUtil.instance.color_506191,
                    borderRadius: BorderRadius.circular(PxUtil.instance.px_8),
                  ),
                  onItemClick: ()=>model.itemTap(StringUtil.instance.Name),
                ),
                SizedBox(height: PxUtil.instance.px_15,),
                //Gender
                CommClickWidget(
                  title: '${StringUtil.instance.Gender}：',
                  itemHeight: PxUtil.instance.px_46,
                  titlecColor: ColorUtil.instance.color_white,
                  titleFontWeight: FontWeight.w500,
                  titleSize: PxUtil.instance.px_13,
                  contColor: ColorUtil.instance.color_white,
                  contFontSize: PxUtil.instance.px_13,
                  contFontWeight: FontWeight.w500,
                  cont: model.getGender(),
                  itemBoxDecoration: BoxDecoration(
                    color: ColorUtil.instance.color_506191,
                    borderRadius: BorderRadius.circular(PxUtil.instance.px_8),
                  ),
                  onItemClick: ()=>model.selectGender(),
                ),
                SizedBox(height: PxUtil.instance.px_15,),
                //Birthday
                CommClickWidget(
                  title: '${StringUtil.instance.Birthday}：',
                  itemHeight: PxUtil.instance.px_46,
                  titlecColor: ColorUtil.instance.color_white,
                  titleFontWeight: FontWeight.w500,
                  titleSize: PxUtil.instance.px_13,
                  contColor: ColorUtil.instance.color_white,
                  contFontSize: PxUtil.instance.px_13,
                  contFontWeight: FontWeight.w500,
                  cont: model.myInfo?.birthday??'',
                  itemBoxDecoration: BoxDecoration(
                    color: ColorUtil.instance.color_506191,
                    borderRadius: BorderRadius.circular(PxUtil.instance.px_8),
                  ),
                  onItemClick: ()=>model.onBirthPressed(),
                ),
                SizedBox(height: PxUtil.instance.px_15,),
                //Signature
                CommClickWidget(
                  title: '${StringUtil.instance.Signature}：',
                  itemHeight: PxUtil.instance.px_46,
                  titlecColor: ColorUtil.instance.color_white,
                  titleFontWeight: FontWeight.w500,
                  titleSize: PxUtil.instance.px_13,
                  contColor: ColorUtil.instance.color_white,
                  contFontSize: PxUtil.instance.px_13,
                  contFontWeight: FontWeight.w500,
                  cont: model.myInfo?.signature??'',
                  itemBoxDecoration: BoxDecoration(
                    color: ColorUtil.instance.color_506191,
                    borderRadius: BorderRadius.circular(PxUtil.instance.px_8),
                  ),
                  onItemClick: ()=>model.itemTap(StringUtil.instance.Signature),
                ),
                SizedBox(height: PxUtil.instance.px_50,),
                Container(
                  margin: EdgeInsets.only(
                    top: PxUtil.instance.px_35,
                  ),
                  child: MainGradientButton(
                    onPressed: ()=>model.submit(),
                    txt: StringUtil.instance.Submit,
                  ),
                ),
              ],
            )
          );
        }
    );
  }
}
